package com.maozzi.web.controller.rest;

import com.maozzi.api.acl.AclService;
import com.maozzi.api.acl.model.RoleDTO;
import com.maozzi.api.auth.annotation.RequirePermissions;
import com.maozzi.api.user.UserService;
import com.maozzi.common.model.PageDTO;
import com.maozzi.common.model.PageParam;
import com.maozzi.common.model.PageVO;
import com.maozzi.common.util.CloneUtil;
import com.maozzi.web.model.RoleVO;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 管理员controller
 *
 * @author maozi
 */
@Slf4j
@RestController
@RequestMapping("/rest/acl")
@RequirePermissions(code = "role:view")
public class AclController {

    @Resource
    private AclService aclService;
    @Resource
    private UserService userService;

    /**
     * 角色分页列表
     *
     * @param vo 查询条件
     * @return 返回
     */
    @GetMapping("rolePage.json")
    public PageVO<RoleVO> rolePage(RoleVO vo, PageParam pageParam) {
        RoleDTO roleDTO = CloneUtil.to(vo, RoleDTO.class);
        PageDTO<RoleDTO> dto = aclService.rolePage(roleDTO, pageParam);

        return CloneUtil.toPageVO(dto, RoleVO.class);
    }

}
